﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using log4net;
using AutoFacUtils;
using CashFlow.Web.Service;
using CashFlow.Web.Common;
using CashFlow.Web.Def;
using CashFlow.Web.Filters;
using CashFlow.Web.Areas.ShopManage.Models.Fee;
using CashFlow.Web.Areas.ShopManage.Validator.Fee;
using IFeeService2 = CashFlow.Web.Areas.ShopManage.Service.IFeeService;

namespace CashFlow.Web.Areas.ShopManage.Controllers
{
    [ShopManagerFilter]
    public class FeeController : Controller
    {
        private IUserService GetUserService() { return AutoFacHelper.Get<IUserService>(); }
        private IFeeService2 GetFeeService2() { return AutoFacHelper.Get<IFeeService2>(); }

        // GET: ShopManage/Fee
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        [ValidatorFilter(typeof(QueryFeeModelValidator))]
        public ActionResult QueryByWhere(QueryFeeModel model)
        {
            var userService = GetUserService();
            var si = userService.GetLoginShopInfo();
            var feeService = GetFeeService2();
            var ls = feeService.QueryByWhere(
                        si.ShopManagerUserId
                        , model.Date
                        , model.Name
                     );
            return MyCommonTool.CreateOperationResult(true, "", ls);
        }
    }
}